import { ActionContext } from "vuex"
import { SysConfig } from "/@/_types/sys/sysconfig"
const state: SysConfig = {
    appId: "",
    appName: "",
    locale: "",
    i18n: false,
    databaseSchema: "",
    cmsExist: false,
    rememberMe: false,
    websocketPath: "",
    randomCode: false,
    userAccountType: "",
    addPerson: false,
    tenantManagerUnit: "",
    loginType: "",
    loginRefreshToken: "",
    oauth2Url: "",
    gatewayUrl: "",
    currentComp: "",
    encodePassword: false,
    corp: "",
    clientid: "",
    rabbitUsername: "",
    rabbitPassword: "",
    rabbitQueuetype: "",
    aeskey: "",
    aesiv: "",
    authHeaderName: "",
    thirdSSOHeaderName: ""
}


const actions = {
    setSysConfig(ctx: ActionContext<SysConfig, {}>, sysconfig: SysConfig) {
        ctx.commit("SET_SYSCONFIG", sysconfig)
    },
}

const mutations = {
    SET_SYSCONFIG(state: SysConfig, sysconfig: SysConfig) {
        state.appId = sysconfig.appId;
        state.appName = sysconfig.appName;
        state.locale = sysconfig.locale;
        state.i18n = sysconfig.i18n;
        state.databaseSchema = sysconfig.databaseSchema;
        state.cmsExist = sysconfig.cmsExist;
        state.rememberMe = sysconfig.rememberMe;
        state.websocketPath = sysconfig.websocketPath;
        state.randomCode = sysconfig.randomCode;
        state.userAccountType = sysconfig.userAccountType;
        state.addPerson = sysconfig.addPerson;
        state.tenantManagerUnit = sysconfig.tenantManagerUnit;
        state.loginType = sysconfig.loginType;
        state.loginRefreshToken = sysconfig.loginRefreshToken;
        state.oauth2Url = sysconfig.oauth2Url;
        state.gatewayUrl = sysconfig.gatewayUrl;
        state.currentComp = sysconfig.currentComp;
        state.encodePassword = sysconfig.encodePassword;
        state.corp = sysconfig.corp;
        state.clientid = sysconfig.clientid;
        state.rabbitUsername = sysconfig.rabbitUsername;
        state.rabbitPassword = sysconfig.rabbitPassword;
        state.rabbitQueuetype = sysconfig.rabbitQueuetype;
        state.aeskey = sysconfig.aeskey;
        state.aesiv = sysconfig.aesiv;
        state.authHeaderName = sysconfig.authHeaderName;
        state.thirdSSOHeaderName = sysconfig.thirdSSOHeaderName;
    },
}

export default {
    namespaced: true,
    state,
    actions,
    mutations
}